<template>
  <el-dialog title="委外订单详情" :close-on-click-modal="false" :visible.sync="visible" center fullscreen append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-form :model="dataForm" ref="dataForm"  label-width="120px">
      <el-row :gutter="15">
        <el-col :span="8">
          <el-form-item label="订单单号" >
            <el-input v-model="dataForm.billId" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="销售单号" >
            <el-input v-model="dataForm.saleBillId" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="订单类型" >
            {{getSaleType(dataForm.consignType)}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="15">
        <el-col :span="8">
          <el-form-item label="审核人" >
            <el-input v-model="dataForm.auditUserName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="制造商" >
            <el-input v-model="dataForm.supplyName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="入库仓位" >
            <el-input v-model="dataForm.inStockName" readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="15">
        <el-col :span="8">
          <el-form-item label="销售门店" >
            <el-input v-model="dataForm.deptName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="顾客姓名" >
            <el-input v-model="dataForm.customerName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="顾客卡号" >
            <el-input v-model="dataForm.customerCard" readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="审核时间" >
        <el-input v-model="dataForm.auditTime" readonly></el-input>
      </el-form-item>
      <el-form-item label="备注" >
        <el-input v-model="dataForm.memo" readonly></el-input>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" border v-loading="dataListLoading">
      <el-table-column prop="billId" label="收货单号" width="140"></el-table-column>
      <el-table-column prop="goodsName" label="商品名称"></el-table-column>
      <el-table-column prop="goodsCode" label="商品代码" width="150"></el-table-column>
      <el-table-column prop="goodsQuantity" label="收货数量" width="80"></el-table-column>
      <el-table-column prop="batch" label="批次" width="100"></el-table-column>
      <el-table-column prop="invalidTime" label="失效日期" width="160"></el-table-column>
      <el-table-column prop="registerNum" label="注册证号" width="160"></el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
    import { checkReceiptDetailByBillId } from '@/api/eims/consign/consignReceipt'
    import { remote } from '@/api/admin/dict'
    import { mapGetters } from 'vuex'
    let params = '/consignInvisiblePrint.cpt&receiptId='
    export default {
    data () {
      return {
        visible: false,
        printUrl:'',
        dataForm: {
        },
        deptOptions: [],
        saleTypeData: [],
        dataList: [],
        optometry: {},
        dataListLoading: false
      }
    },
    computed: {
        ...mapGetters(['permissions','bizData','userInfo'])
    },
    methods: {
      init(billId) {
        remote('sale_type').then(result => {
          this.saleTypeData = result.data.data
        })
        this.visible = true
        this.dataList = []
        this.$nextTick(() => {
          this.dataListLoading = true
          checkReceiptDetailByBillId(billId).then(response => {
            if(response.data.code == '0'){
              this.dataForm = response.data.data
              let goodsData = response.data.data.detailList
              this.dataList = goodsData
            }else{
              this.$message.error(response.data.msg)
            }
            this.dataListLoading = false
          })
        })
      },
      //获取配镜类型枚举
      getSaleType(value) {
          let obj = {};
          obj = this.saleTypeData.find((item)=>{
              return item.value == value;
          });
          if(obj && obj.label){
              return obj.label;
          }
      },
      //   获取品牌打印的参数
      getPrintParams(){
          let receiptId = this.dataForm.id
          this.printUrl = this.bizData.printUrl + params + receiptId
      }
    }
  }
</script>

<style lang="scss" scoped="scoped">
  .miui-table {
    width: 100%;
    margin: 10px 0;
    tr th,tr td {
      background-color: #b1e2ec3b;
    }
    tr th, tr td {
      padding: 10px 8px;
      border: solid 1px #f7f7f7;
      text-align: center;
    }
  }
</style>
